package com.mdxq.mall.user.study;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/config")
// 自动监听配置中心对于属性内容的改变,无需重启服务即可获得最新的配置内容
@RefreshScope
public class ConfigTestController {
    @Value("${app.env}")
    private String appEnv;//保存刚刚添加到配置中心的内容

    @GetMapping("/a")
    public ResponseEntity<String> a(){
                                                // 返回200+ 内容              返回404
        return appEnv!=null?ResponseEntity.ok("当前应用环境"+appEnv):ResponseEntity.notFound().build();
    }
}
